package 狂神.GUI;

import sun.text.resources.cldr.es.FormatData_es_419;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @ClassName: Exercise
 * @Auther: Drawin
 * @Date: 2021/12/23 14:55
 * @Description:
 */

public class Exercise {
    public static void main(String[] args) {
        //界面框架
        Frame frame = new Frame("homework");
        frame.setLayout(new GridLayout(2,1));
        frame.setSize(400,400);
        frame.setVisible(true);
        frame.setBackground(Color.cyan);
        frame.setLocation(400,400);

        //面板
        Panel p1 = new Panel(new BorderLayout());
        Panel p2 = new Panel(new GridLayout(2,1));
        Panel p3 = new Panel(new BorderLayout());
        Panel p4 = new Panel(new GridLayout(2,2));


        //上面
        p1.add(new Button("east-1"),BorderLayout.EAST);
        p1.add(new Button("west-1"),BorderLayout.WEST);
        p1.add(p2,BorderLayout.CENTER);
        p2.add(new Button("up-1"));
        p2.add(new Button("up-2"));

        //下面
        p3.add(new Button("east-2"),BorderLayout.EAST);
        p3.add(new Button("west-2"),BorderLayout.WEST);
        for (int i = 0; i < 4; i++) {
            p4.add(new Button("down-"+i));
        }
        p3.add(p4,BorderLayout.CENTER);

        frame.add(p1);
        frame.add(p3);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
               System.exit(0);
            }
        });

    }
}
